/**
* Class Name: ifulfillViewDependantFIControllerTest
* Author: Accenture
* Date: 19-July-2011
* Requirement/Project Name: iFulfill
* Requirement/Project Description: Test class for ifulfillViewDependantFIController
**/

@istest
private class ifulfillViewDependantFIControllerTest 
{
    /**
    *  Test method. 
    *
    */
    public static testmethod  void testGetDependantFIObjects()
    {
        list<Fullfilment_Item__c> FIlist = new list<Fullfilment_Item__c>();
        PageReference pg = Page.ifulfillViewDependantFulfillItem;
        Account acc = new Account(name= 'xyx');
        
        Profile p = [select id from profile where name='System Administrator'];           
        User u = new User(alias = 'sysad', email='sysadmin@accenture.com',emailencodingkey='UTF-8', lastname='Tes12', languagelocalekey='en_US',localesidkey='en_US', profileid = p.Id,timezonesidkey='Asia/Calcutta', username='testad123@testorg.com');           
        Insert u;     
        
        insert acc;
        Test.setCurrentPage(pg); 
        Fullfilment_Item__c FI = new Fullfilment_Item__c(Account__c = acc.id,Main_Listing_Phone_Number__c = '100',Listed_Name__c ='XYZ',Heading_Name__c ='Heading name',Item_Id__c = 'Item id' ,Product_Code__c ='p1',UDAC__c ='Udac1',Region__c = 'region1',Transaction_Type__c ='New', ownerid = u.id,group_id__c =2);
        Fullfilment_Item__c FI2 = new Fullfilment_Item__c(Account__c = acc.id,Main_Listing_Phone_Number__c = '100',Listed_Name__c ='XYZ2',Heading_Name__c ='Heading2 name',Item_Id__c = 'Item id123' ,Product_Code__c ='p1',UDAC__c ='Udac1',Region__c = 'region1',Transaction_Type__c ='New', ownerid = u.id);
        Fullfilment_Item__c FI3 = new Fullfilment_Item__c(Account__c = acc.id,Main_Listing_Phone_Number__c = '104560',Listed_Name__c ='XMIne',Heading_Name__c ='Test name',Item_Id__c = 'Item id123' ,Product_Code__c ='p1',UDAC__c ='Udac1',Region__c = 'region1',Transaction_Type__c ='New', ownerid = u.id);
        Fullfilment_Item__c FI4 = new Fullfilment_Item__c(Account__c = acc.id,Main_Listing_Phone_Number__c = '104560',Listed_Name__c ='XIne',Heading_Name__c ='Test Get grouped',Item_Id__c = 'Item id123' ,Product_Code__c ='p1',UDAC__c ='Udac1',Region__c = 'region1',Transaction_Type__c ='New', ownerid = u.id,group_id__c =2);
       
        FIlist.add(FI); 
        FIlist.add(FI2);
        FIlist.add(FI3);
        FIlist.add(FI4);

        insert FIlist;
       
        ApexPages.StandardController sc = new ApexPages.StandardController(FI2);
        ApexPages.StandardController sc1 = new ApexPages.StandardController(FI3);        
        ApexPages.StandardController sc2 = new ApexPages.StandardController(FI4);

        ifulfillViewDependantFIController controller = new ifulfillViewDependantFIController(sc);
        ifulfillViewDependantFIController controller1 = new ifulfillViewDependantFIController(sc1);
        ifulfillViewDependantFIController controller2 = new ifulfillViewDependantFIController(sc2);

        controller.getGroupedItems();       
        controller.getsearchedRelatedItems();
        controller.doGroup();
        controller1.getGroupedItems();
        controller1.getsearchedRelatedItems();
        controller1.doGroup();
        controller1.doDelink();
        controller2.getGroupedItems();
    }
}